/**
 * 文件名称:ChipmodelAction.java
 * 文件版权:ChinaParasol Technologies Co., Ltd. Copyright 1998-2020, All rights reserved
 * 文件描述:<描述>
 * 修改作者:LiXiangDong
 * 修改时间:Jan 7, 2013
 */
package com.parasol.hcerp.service.chipmodel.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.parasol.hcerp.common.action.ParasolAction;
import com.parasol.hcerp.service.chipmodel.domain.ChipmodelBean;
import com.parasol.hcerp.service.chipmodel.service.ChipmodelService;

/**
 * 
 * @author  LiXiangDong
 * @version V1.0
 */
public class ChipmodelAction extends ParasolAction
{
    
    /**
     * 注释内容
     */
    private static final long serialVersionUID = 7445284538883521971L;
    
    private ChipmodelService chipmodelService = null;
    
    private ChipmodelBean chipmodelBean = null;
    
    private String chipmodelid = null;
    
    public ChipmodelService getChipmodelService()
    {
        return chipmodelService;
    }

    public void setChipmodelService(ChipmodelService chipmodelService)
    {
        this.chipmodelService = chipmodelService;
    }

    public String queryForList()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        List<ChipmodelBean> chipmodelList = chipmodelService.queryForList();
        request.setAttribute("chipmodelList", chipmodelList);
        return SUCCESS;
    }
    
    public String saveForJump()
    {
        super.clientCache();
        return SUCCESS;
    }
    
    public String saveForChipmodel()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        int result = chipmodelService.queryForExist(chipmodelBean);
        if (result > 0)
        {
            request.setAttribute("errorMessage", "芯片型号已经存在");
            return ERROR;
        }
        
        chipmodelService.saveForChipmodel(chipmodelBean);
        
        List<ChipmodelBean> chipmodelList = chipmodelService.queryForList();
        request.setAttribute("chipmodelList", chipmodelList);
        return SUCCESS;
    }
    
    public String updateForJump()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        chipmodelBean = chipmodelService.queryForChipmodel(chipmodelid);
        request.setAttribute("chipmodelBean", chipmodelBean);
        return SUCCESS;
    }
    
    public String updateForChipmodel()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        int result = chipmodelService.queryForExist(chipmodelBean);
        if (result > 0)
        {
            request.setAttribute("errorMessage", "芯片型号已经存在");
            return ERROR;
        }
        
        chipmodelService.updateForChipmodel(chipmodelBean);
        
        List<ChipmodelBean> chipmodelList = chipmodelService.queryForList();
        request.setAttribute("chipmodelList", chipmodelList);
        return SUCCESS;
    }
    
    public String deleteForChipmodel()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        
        int result = chipmodelService.queryForUse(chipmodelid);
        if (result > 0)
        {
            request.setAttribute("errorMessage", "芯片型号已经使用，不能删除");
            return ERROR;
        }
        else
        {
            chipmodelService.deleteForChipmodel(chipmodelid);
        }
        
        List<ChipmodelBean> chipmodelList = chipmodelService.queryForList();
        request.setAttribute("chipmodelList", chipmodelList);
        return SUCCESS;
    }
    
    public String showForChipmodel()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        chipmodelBean = chipmodelService.queryForChipmodel(chipmodelid);
        request.setAttribute("chipmodelBean", chipmodelBean);
        return SUCCESS;
    }
    
    
    public String selectCommodity()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        List<ChipmodelBean> chipmodelList = chipmodelService.queryForList();
        request.setAttribute("chipmodelList", chipmodelList);
        return SUCCESS;
    }

    public ChipmodelBean getChipmodelBean()
    {
        return chipmodelBean;
    }

    public void setChipmodelBean(ChipmodelBean chipmodelBean)
    {
        this.chipmodelBean = chipmodelBean;
    }

    public String getChipmodelid()
    {
        return chipmodelid;
    }

    public void setChipmodelid(String chipmodelid)
    {
        this.chipmodelid = chipmodelid;
    }
    
}
